import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/double_control_entity.dart';

DoubleControlEntity $DoubleControlEntityFromJson(Map<String, dynamic> json) {
  final DoubleControlEntity doubleControlEntity = DoubleControlEntity();
  final int? level = jsonConvert.convert<int>(json['level']);
  if (level != null) {
    doubleControlEntity.level = level;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    doubleControlEntity.name = name;
  }
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    doubleControlEntity.id = id;
  }
  final List<DoubleControlChildren>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DoubleControlChildren>(e) as DoubleControlChildren).toList();
  if (children != null) {
    doubleControlEntity.children = children;
  }
  return doubleControlEntity;
}

Map<String, dynamic> $DoubleControlEntityToJson(DoubleControlEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['level'] = entity.level;
  data['name'] = entity.name;
  data['id'] = entity.id;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['isChecked'] = entity.isChecked;
  return data;
}

extension DoubleControlEntityExtension on DoubleControlEntity {
  DoubleControlEntity copyWith({
    int? level,
    String? name,
    String? id,
    List<DoubleControlChildren>? children,
    bool? isChecked,
  }) {
    return DoubleControlEntity()
      ..level = level ?? this.level
      ..name = name ?? this.name
      ..id = id ?? this.id
      ..children = children ?? this.children
      ..isChecked = isChecked ?? this.isChecked;
  }
}

DoubleControlChildren $DoubleControlChildrenFromJson(Map<String, dynamic> json) {
  final DoubleControlChildren doubleControlChildren = DoubleControlChildren();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    doubleControlChildren.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    doubleControlChildren.name = name;
  }
  final List<DoubleControlChildren>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DoubleControlChildren>(e) as DoubleControlChildren).toList();
  if (children != null) {
    doubleControlChildren.children = children;
  }
  final int? level = jsonConvert.convert<int>(json['level']);
  if (level != null) {
    doubleControlChildren.level = level;
  }
  final int? taskCount = jsonConvert.convert<int>(json['taskCount']);
  if (taskCount != null) {
    doubleControlChildren.taskCount = taskCount;
  }
  final String? parentId = jsonConvert.convert<String>(json['parentId']);
  if (parentId != null) {
    doubleControlChildren.parentId = parentId;
  }
  final String? initialRiskLevel = jsonConvert.convert<String>(json['initialRiskLevel']);
  if (initialRiskLevel != null) {
    doubleControlChildren.initialRiskLevel = initialRiskLevel;
  }
  final String? currentRiskLevel = jsonConvert.convert<String>(json['currentRiskLevel']);
  if (currentRiskLevel != null) {
    doubleControlChildren.currentRiskLevel = currentRiskLevel;
  }
  final String? controlMeasures = jsonConvert.convert<String>(json['control_measures']);
  if (controlMeasures != null) {
    doubleControlChildren.controlMeasures = controlMeasures;
  }
  final String? hazardDep = jsonConvert.convert<String>(json['hazardDep']);
  if (hazardDep != null) {
    doubleControlChildren.hazardDep = hazardDep;
  }
  final String? hazardLiablePerson = jsonConvert.convert<String>(json['hazardLiablePerson']);
  if (hazardLiablePerson != null) {
    doubleControlChildren.hazardLiablePerson = hazardLiablePerson;
  }
  final bool? isChecked = jsonConvert.convert<bool>(json['isChecked']);
  if (isChecked != null) {
    doubleControlChildren.isChecked = isChecked;
  }
  final String? dataSrc = jsonConvert.convert<String>(json['dataSrc']);
  if (dataSrc != null) {
    doubleControlChildren.dataSrc = dataSrc;
  }
  final String? hazardDepId = jsonConvert.convert<String>(json['hazardDepId']);
  if (hazardDepId != null) {
    doubleControlChildren.hazardDepId = hazardDepId;
  }
  final String? hazardLiablePersonId = jsonConvert.convert<String>(json['hazardLiablePersonId']);
  if (hazardLiablePersonId != null) {
    doubleControlChildren.hazardLiablePersonId = hazardLiablePersonId;
  }
  final String? hazardDistinguishPersonId = jsonConvert.convert<String>(json['hazardDistinguishPersonId']);
  if (hazardDistinguishPersonId != null) {
    doubleControlChildren.hazardDistinguishPersonId = hazardDistinguishPersonId;
  }
  final String? hazardDistinguishPerson = jsonConvert.convert<String>(json['hazardDistinguishPerson']);
  if (hazardDistinguishPerson != null) {
    doubleControlChildren.hazardDistinguishPerson = hazardDistinguishPerson;
  }
  final String? hazardDistinguishDep = jsonConvert.convert<String>(json['hazardDistinguishDep']);
  if (hazardDistinguishDep != null) {
    doubleControlChildren.hazardDistinguishDep = hazardDistinguishDep;
  }
  return doubleControlChildren;
}

Map<String, dynamic> $DoubleControlChildrenToJson(DoubleControlChildren entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  data['level'] = entity.level;
  data['taskCount'] = entity.taskCount;
  data['parentId'] = entity.parentId;
  data['initialRiskLevel'] = entity.initialRiskLevel;
  data['currentRiskLevel'] = entity.currentRiskLevel;
  data['control_measures'] = entity.controlMeasures;
  data['hazardDep'] = entity.hazardDep;
  data['hazardLiablePerson'] = entity.hazardLiablePerson;
  data['isChecked'] = entity.isChecked;
  data['dataSrc'] = entity.dataSrc;
  data['hazardDepId'] = entity.hazardDepId;
  data['hazardLiablePersonId'] = entity.hazardLiablePersonId;
  data['hazardDistinguishPersonId'] = entity.hazardDistinguishPersonId;
  data['hazardDistinguishPerson'] = entity.hazardDistinguishPerson;
  data['hazardDistinguishDep'] = entity.hazardDistinguishDep;
  return data;
}

extension DoubleControlChildrenExtension on DoubleControlChildren {
  DoubleControlChildren copyWith({
    String? id,
    String? name,
    List<DoubleControlChildren>? children,
    int? level,
    int? taskCount,
    String? parentId,
    String? initialRiskLevel,
    String? currentRiskLevel,
    String? controlMeasures,
    String? hazardDep,
    String? hazardLiablePerson,
    bool? isChecked,
    String? dataSrc,
    String? hazardDepId,
    String? hazardLiablePersonId,
    String? hazardDistinguishPersonId,
    String? hazardDistinguishPerson,
    String? hazardDistinguishDep,
  }) {
    return DoubleControlChildren()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..children = children ?? this.children
      ..level = level ?? this.level
      ..taskCount = taskCount ?? this.taskCount
      ..parentId = parentId ?? this.parentId
      ..initialRiskLevel = initialRiskLevel ?? this.initialRiskLevel
      ..currentRiskLevel = currentRiskLevel ?? this.currentRiskLevel
      ..controlMeasures = controlMeasures ?? this.controlMeasures
      ..hazardDep = hazardDep ?? this.hazardDep
      ..hazardLiablePerson = hazardLiablePerson ?? this.hazardLiablePerson
      ..isChecked = isChecked ?? this.isChecked
      ..dataSrc = dataSrc ?? this.dataSrc
      ..hazardDepId = hazardDepId ?? this.hazardDepId
      ..hazardLiablePersonId = hazardLiablePersonId ?? this.hazardLiablePersonId
      ..hazardDistinguishPersonId = hazardDistinguishPersonId ?? this.hazardDistinguishPersonId
      ..hazardDistinguishPerson = hazardDistinguishPerson ?? this.hazardDistinguishPerson
      ..hazardDistinguishDep = hazardDistinguishDep ?? this.hazardDistinguishDep;
  }
}
